const api = wss => {
    const wsList = new Map()
    wss.on('connection', function connection(ws, req) {
        const url = req.url
        const [, roomId, userid] = /\/(\w+)\/(\w+)/.exec(url)
        console.log(roomId, userid)
        wsList.set(userid, {ws, userid, roomId})
        ws.on('message', (message) => {
            console.log(message)
        });

        ws.on("close", function () {
            wsList.delete(userid)
        })
    });
}
export default api
